// 定义懒加载插件
import { useIntersectionObserver } from '@vueuse/core'
export const directivePlugin = {
  install (app) {
    app.directive('img-lazy', {
      mounted (el, bind) {
        const { stop } = useIntersectionObserver(
          el,  //需要监听的dom
          ([{ isIntersecting }]) => {
            if (isIntersecting) {
              el.src = bind.value
              stop()
            }
          },
        )
      }
    })
  }
}